home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F18774_PremiershipResults.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-04-14  |  4.1 KB  |  122 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:include href="..\..\..\Libraries\datetime_lib.xsl"/>
  4. <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
  5.  
  6. <xsl:key name="kDistinctDates" match="result" use="@date"/>
  7. <xsl:key name="kDistinctGameScorers" match="scorer" use="concat(generate-id(parent::*),@name)"/>
  8. <xsl:template match="/">
  9.     <html>
  10.         <head>
  11.             <title>
  12.                 <xsl:value-of select="/results/@nation"/>
  13.                 <xsl:text> </xsl:text>
  14.                 <xsl:value-of select="/results/@sponsor"/>
  15.                 <xsl:text> </xsl:text>
  16.                 <xsl:value-of select="/results/@league"/>
  17.                 <xsl:text> (results)</xsl:text>
  18.             </title>
  19.         </head>
  20.         <body>
  21.             <h3>
  22.                 <xsl:value-of select="/results/@nation"/>
  23.                 <xsl:text> </xsl:text>
  24.                 <xsl:value-of select="/results/@sponsor"/>
  25.                 <xsl:text> </xsl:text>
  26.                 <xsl:value-of select="/results/@league"/>
  27.                 <xsl:text> (results)</xsl:text>
  28.             </h3>
  29.             <table border="0" cellpadding="0" cellspacing="0">
  30.                 <tr>
  31.                     <td width="150"></td>
  32.                     <td width="40"></td>
  33.                     <td width="150"></td>
  34.                     <td width="50"></td>
  35.                 </tr>
  36.                 <xsl:apply-templates select="results/result[generate-id() = generate-id(key('kDistinctDates',@date))]" mode="distinct-date">
  37.                     <xsl:sort select="translate(@date,'-','')" data-type="number"/>
  38.                 </xsl:apply-templates>
  39.             </table>
  40.         </body>
  41.     </html>
  42. </xsl:template>
  43.  
  44. <xsl:template match="result" mode="distinct-date">
  45.     <tr>
  46.         <td colspan="4" align="center" style="color: Navy; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 9pt;">
  47.             <hr noshade="yes"/>
  48.             <xsl:call-template name="format-date-time">
  49.                 <xsl:with-param name="datetime" select="@date"/>
  50.                 <xsl:with-param name="format-string" select="'dowwww, dth mmmm yyyy'"/>
  51.             </xsl:call-template>
  52.         </td>
  53.     </tr>
  54.     <xsl:apply-templates select="key('kDistinctDates',@date)" mode="show-result">
  55.         <xsl:sort select="home/@team"/>
  56.     </xsl:apply-templates>
  57. </xsl:template>
  58.  
  59. <xsl:template match="result" mode="show-result">
  60.     <tr>
  61.         <td colspan="4" height="5"></td>
  62.     </tr>
  63.     <tr style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;">
  64.         <td align="left" style="color: Navy; font-weight: bold;">
  65.             <xsl:value-of select="home/@team"/>
  66.         </td>
  67.         <td align="center">
  68.             <xsl:text>(</xsl:text>
  69.             <xsl:value-of select="count(home/scorer[@min <= 45])"/>
  70.             <xsl:text>-</xsl:text>
  71.             <xsl:value-of select="count(away/scorer[@min <= 45])"/>
  72.             <xsl:text>) </xsl:text>
  73.             <xsl:value-of select="home/@score"/>
  74.             <xsl:text>-</xsl:text>
  75.             <xsl:value-of select="away/@score"/>
  76.         </td>
  77.         <td align="right" style="color: Navy; font-weight: bold;">
  78.             <xsl:value-of select="away/@team"/>
  79.         </td>
  80.         <td align="right">
  81.             <xsl:value-of select="format-number(@attendance,'#,##0')"/>
  82.         </td>
  83.     </tr>
  84.     <xsl:if test="home/@score != 0 or away/@score != 0">
  85.         <tr style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;">
  86.             <td align="left" valign="top">
  87.                 <xsl:apply-templates select="home" mode="show-scorers"/>
  88.             </td>
  89.             <td></td>
  90.             <td align="right" valign="top">
  91.                 <xsl:apply-templates select="away" mode="show-scorers"/>
  92.             </td>
  93.             <td></td>
  94.         </tr>
  95.     </xsl:if>
  96. </xsl:template>
  97.  
  98. <xsl:template match="home|away" mode="show-scorers">
  99.     <xsl:for-each select="scorer[generate-id() = generate-id(key('kDistinctGameScorers',concat(generate-id(parent::*),@name)))]">
  100.         <xsl:sort select="min" data-type="number"/>
  101.         <xsl:value-of select="@name"/>
  102.         <xsl:for-each select="key('kDistinctGameScorers',concat(generate-id(parent::*),@name))">
  103.             <xsl:text> </xsl:text>
  104.             <xsl:value-of select="@min"/>
  105.             <xsl:choose>
  106.                 <xsl:when test="@type = 'pen'">
  107.                     <xsl:text>(pen)</xsl:text>
  108.                 </xsl:when>
  109.                 <xsl:when test="@type = 'og'">
  110.                     <xsl:text>(og)</xsl:text>
  111.                 </xsl:when>
  112.             </xsl:choose>
  113.             <xsl:if test="position() != last()">
  114.                 <xsl:text>,</xsl:text>
  115.             </xsl:if>
  116.         </xsl:for-each>
  117.         <xsl:if test="position() != last()">
  118.             <br/>
  119.         </xsl:if>
  120.     </xsl:for-each>
  121. </xsl:template>
  122. </xsl:stylesheet>